package com.java.URL_UrlConnection;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;

public class URLAndUrlConnectionAPI {
    public static void main(String[] args) throws IOException {
        // 创建对象
        URL url = new URL("http://www.baidu.com");

        // openConnection：打开链接
        URLConnection urlConnection = url.openConnection();

        // setXxx：设置Xxx信息
        urlConnection.setRequestProperty("POST", "http://www.baidu.com");

        // getXxx：获取Xxx信息
        System.out.println(urlConnection.getDate()); // 1710747287000
        System.out.println(urlConnection.getContent()); // sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@58372a00
        System.out.println(urlConnection.getContentType()); // text/html
        System.out.println(urlConnection.getContentLength()); // 2381
    }
}
